var reviveCount = 5;
var mapIds = [350013100, 350013200, 350013300, 350013400, 350013500];
var 准备地图 = 350013000;
var eventName = "黑色天堂_Act1_奥尔卡的内心世界";
var mobId;
var mob;
var setupTask;

function init() {
    em.setProperty("leader", "true");
    em.setProperty("state", "0")
}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance(eventName);
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.killAllMonsters(true);
        d.modifySpawnPoint4Event(0)
    }
    return c
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(1000 * 60 * 30);
    b.setProperty("phase", "1")
}

function onMonsterKilled(b, c) {
    var e = p.getMapId();
    if (e != 350013300) {
        return
    }
    var f = 4000890;
    if (player.getAPI().getNumberFromQuestInfo(33142, "box2") < 2) {
        var d = 20;
        var a = em.getNumberProperty("stage" + 3 + "_kill") + 1;
        em.setProperty("stage" + 3 + "_kill", a);
        if (a > d) {
            return
        }
        player.dropMessage(-1, "消灭数量：" + (a) + "/" + d + "");
        if (d - a == 1) {
            player.getAPI().addPopupSay(1540530, 1500, "快跟我说实话。\r\n你是不是因为想见我, 所以才一直跑过来的?", "", 0)
        } else {
            if (d - a == 10) {
                player.getAPI().addPopupSay(1540530, 1000, "现在只剩下10只了。\r\n加油吧。", "", 0)
            } else {
                if (a == d) {
                    player.removeAll(f, false);
                    player.getAPI().addPopupSay(1540530, 2000, "怪物们被击退了。现在可以转动碎片了。", "");
                    player.getAPI().getMap().getReactorByName("firstBox").forceHitReactor(player, 1);
                    player.getAPI().setNumberForQuestInfo(33142, "box2", 2);
                    player.getMap().modifySpawnPoint4Event(2);
                    player.getMap().killAllMonsters(true)
                }
            }
        }
    } else {
        var d = 60;
        var a = em.getNumberProperty("stage" + 4 + "_kill") + 1;
        if (a <= 20 && c == 8240023 || a > 20 && a <= 40 && c == 8240025 || a > 40 && c == 8240024) {
            em.setProperty("stage" + 4 + "_kill", a);
            if (a > d) {
                return
            }
            player.dropMessage(-1, "消灭数量：" + (a) + "/" + d + "");
            if (a == 5) {
                player.getAPI().addPopupSay(1540530, 1500, "绝不是我懒得转动碎片, 所以才命令你的。", "", 0)
            } else {
                if (a == 10) {
                    player.getAPI().addPopupSay(1540530, 1000, "现在只剩下10只了。\r\n加油吧。", "", 0)
                } else {
                    if (a == 20) {
                        player.removeAll(f, false);
                        player.getAPI().addPopupSay(1540530, 2000, "怪物们被击退了。现在可以转动碎片了。", "");
                        player.getAPI().getMap().getReactorByName("redBox").forceHitReactor(player, 1);
                        player.getMap().modifySpawnPoint4Event(4);
                        player.getMap().killAllMonsters(true)
                    } else {
                        if (a == 25) {
                            player.getAPI().addPopupSay(1540530, 1500, "没想到你这么敏捷……\r\n嗯?没什么啦。", "", 0)
                        } else {
                            if (a == 30) {
                                player.getAPI().addPopupSay(1540530, 1000, "现在只剩下10只了。\r\n加油吧。", "", 0)
                            } else {
                                if (a == 35) {
                                    player.getAPI().addPopupSay(1540530, 1500, "以前我也不是兔子玩偶。你难道不想知道我的过去吗?", "", 0)
                                } else {
                                    if (a == 40) {
                                        player.removeAll(f, false);
                                        player.getAPI().addPopupSay(1540530, 2000, "怪物们被击退了。现在可以转动碎片了。", "");
                                        player.getAPI().getMap().getReactorByName("yellowBox").forceHitReactor(player, 1);
                                        player.getAPI().addPopupSay(1540530, 1500, "最后一次了。只要抓住20只蓝色晶莹果冻怪就行了。", "", 0);
                                        player.getAPI().addPopupSay(1540530, 1500, "晶莹果冻怪眼光太高了, \r\n总是跟着我, 我都要烦死了。", "", 0);
                                        player.getMap().modifySpawnPoint4Event(3);
                                        player.getMap().killAllMonsters(true)
                                    } else {
                                        if (a == 60) {
                                            player.removeAll(f, false);
                                            player.getAPI().addPopupSay(1540530, 2000, "怪物们被击退了。现在可以转动碎片了。", "");
                                            player.getAPI().getMap().getReactorByName("blueBox").forceHitReactor(player, 1);
                                            player.getMap().killAllMonsters(true);
                                            player.getMap().setSpawn(false)
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 1
}

function onMapChanged(c, b, a) {
    switch (a) {
        case 350013100:
            initProp("stage1_kill", 0);
            break;
        case 350013200:
            c.getMapInstance(a).modifySpawnPoint4Event(1);
            c.getMapInstance(a).killAllMonsters(true);
            break;
        case 350013300:
            c.getMapInstance(a).modifySpawnPoint4Event(1);
            c.getMapInstance(a).killAllMonsters(true);
            initProp("stage3_kill", 0);
            initProp("stage4_kill", 0);
            initProp("stage4_count", 0);
            break;
        case 350013400:
            break;
        case 350013500:
            initProp("stage6_color", 0);
            break;
        default:
            on玩家退场(c, b, false);
            break
    }
    return
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}

function onPlayerRevived(b, a) {
    return false
}

function onMonsterDamaged() {}
var setupTask;

function onItemPickedUp(b, a, d) {
    if (d != 4000890) {
        return
    }
    var e = a.getItemAmount(d);
    var c = p.getMapId();
    if (c == 350013200) {
        if (a.getAPI().getNumberFromQuestInfo(33142, "box2") < 1) {
            a.dropMessage(-1, "小兔子玩偶 " + e + " / " + 20);
            if (e == 5) {
                a.getAPI().addPopupSay(1540530, 1500, "晶莹果冻怪眼光太高了, \r\n总是跟着我, 我都要烦死了。", "")
            } else {
                if (e == 10) {
                    a.getAPI().addPopupSay(1540530, 1000, "再搜集10个就行了。\r\n加油吧。", "")
                } else {
                    if (e == 20) {
                        a.getAPI().addPopupSay(1540530, 2000, "传送口开启了。", "");
                        a.getMap().getReactorByName("rabbitBox1").forceHitReactor(a, 1);
                        a.getMap().modifySpawnPoint4Event(2);
                        a.getMap().killAllMonsters(true)
                    }
                }
            }
        } else {
            a.dropMessage(-1, "小兔子玩偶 " + e + " / " + 30);
            if (e == 1) {
                a.getAPI().addPopupSay(1540530, 1500, "你的耳朵很短, 皮肤也不白……\r\n虽然你一点也不可爱, 但……\r\n还是希望你能努力地生活。", "", 0);
                a.getAPI().addPopupSay(1540530, 1500, "没想到你这么敏捷……\r嗯?没什么啦。", "")
            } else {
                if (e == 10) {
                    a.getAPI().addPopupSay(1540530, 1000, "还剩下20个。", "")
                } else {
                    if (e == 15) {
                        a.getAPI().addPopupSay(1540530, 1500, "快跟我说实话。\r\n你是不是因为想见我, 所以才一直跑过来的?", "")
                    } else {
                        if (e == 20) {
                            a.getAPI().addPopupSay(1540530, 1000, "再搜集10个就行了。\r\n加油吧。", "");
                            a.getAPI().addPopupSay(1540530, 1500, "我不喜欢胡萝卜。\r\n你为什么用这种眼神看着我?\r\n带着有色眼镜看人是不好的。", "");
                            a.getAPI().addPopupSay(1540530, 1500, "以前我也不是兔子玩偶。你难道不想知道我的过去吗?", "", 0)
                        } else {
                            if (e == 30) {
                                a.getAPI().addPopupSay(1540530, 2000, "传送口开启了。", "");
                                a.getMap().getReactorByName("rabbitBox2").forceHitReactor(a, 1);
                                a.getMap().killAllMonsters(true);
                                a.getMap().setSpawn(false)
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (c == 350013500) {
            if (e <= 30) {
                a.dropMessage(-1, "小兔子玩偶 " + e + " / " + 30)
            }
            if (e == 1) {
                a.getAPI().addPopupSay(1540530, 2000, "没想到你这么敏捷……\r\n嗯？没什么啦。", "")
            } else {
                if (e == 10) {
                    a.getAPI().addPopupSay(1540530, 2000, "时间不多了。\r\n不过请不要太着急。\r\n你走了之后，我又是孤零零的一个人了。", "");
                    a.getAPI().addPopupSay(1540530, 2000, "必须再搜集20个兔子玩偶。", "")
                } else {
                    if (e == 30) {
                        a.getMap().killAllMonsters(true);
                        a.getMap().setSpawn(false);
                        a.getAPI().addPopupSay(1540530, 2000, "传送口开启了。", "");
                        a.getMap().getReactorByName("rabbitBox3").forceHitReactor(a, 1);
                        a.getMap().getReactorByName("box1").forceHitReactor(a, 1);
                        a.getMap().getReactorByName("box2").forceHitReactor(a, 1);
                        a.getMap().getReactorByName("box3").forceHitReactor(a, 1);
                        a.getMap().getReactorByName("box4").forceHitReactor(a, 1);
                        a.getMap().getReactorByName("box5").forceHitReactor(a, 1);
                        a.getMap().getReactorByName("box6").forceHitReactor(a, 1);
                        a.getMap().getReactorByName("box7").forceHitReactor(a, 1)
                    }
                }
            }
        }
    }
}

function clearMob(c, b) {
    for (var a = 0; a < c.getPlayerCount(); a++) {
        c.getPlayers().get(a).getAPI().killAllMob()
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};